package main;

import io.*;

/**
 * This is the initializer class that initializes the project
 * 
 * @author Alex
 *
 */
public class Initializer {

	
	
	/**
	 * The constructor
	 */
	public Initializer()
	{
		//Do nothing
	}
	
	/**
	 * This function initializes all that is needed
	 */
	public void init()
	{
		initDb(true, false);
	}
	
	/**
	 * This is the destructor, what will be run when the user 
	 * 		exits the program
	 */
	protected void finalize() throws Throwable
	{
		closeDb();
		
		super.finalize();
	}
	
	/**
	 * Initialize the db and the connection to it
	 * 
	 * @param isFromTau - is the connection established from TAU
	 */
	private void initDb(boolean isFromTau, boolean isLocal)
	{
		SqlDb db = new SqlDb();
		db.openConnection(isFromTau, isLocal);
	}
	
	/**
	 * Close the connection to the db
	 */
	private void closeDb()
	{
		SqlDb db = new SqlDb();
		db.closeConnection();
	}
}
